<?php
namespace app\admin\controller;
use think\Request;
use app\admin\controller\Base;
use app\admin\model\Component as Components;
use app\admin\model\Page;
use think\facade\View;
use app\admin\model\PageComponent as PageComponents;
class PageComponent extends Base
{
    public function index(Request $request)
    {
        $d = PageComponents::with(['page','component'])->select()->each(function($item){
            $item->page_name = $item->page->name;
            $item->component_name = $item->component?$item->component->name:"";
        });
        return msg::list($d,100);
    }
    public function editConfig(Request $request){
        $data = Components::field('config')->find($request->param('id'));
        $page = new Page;
        return View::display($page->getContent(3));
    }
}
